JavaScript:Canvas API
Canvas API
getElementById()
canvasタグのDOMオブジェクトを取得
getContext()
描画コンテキストを取得
Canvas API - Web API | MDN
code:script.js
// 表示領域を作る
const editor = document.getElementById('editor');
editor.insertAdjacentHTML('beforeend',`
<canvas id="canvas" style="width:600px;height:500px;" >
</canvas>
`);
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 150, 100);
js-script-button.icon(実行ボタン)
HTML5:canvas要素
HTML5:Canvas API
CanvasAPI:描画コンテキスト
JavaScript.icon
#JavaScript-API
https://img.shields.io/badge/JavaScript-Canvas_API-F7DF1E.svg?logo=javascript&style=for-the-badge
MDN.icon